<template>
  <div class="newsListWrap">
    <!-- top -->
    <div class="box1">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="">
          <el-input
            v-model="formInline.user"
            placeholder="请输入要查询的新闻"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search">查询</el-button>
          <el-button
            type="primary"
            icon="el-icon-plus"
            @click="dialogVisible = true"
            >添加</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <!-- table -->
    <div class="box2">
      <el-table :data="tableData" border style="width: 100%" size="small">
        <el-table-column prop="title" label="标题"> </el-table-column>
        <el-table-column prop="author" label="作者"> </el-table-column>
        <el-table-column prop="time" label="发布时间"> </el-table-column>
        <el-table-column prop="act" label="操作">
          <el-button type="primary" icon="el-icon-edit" size="small"
            >编辑</el-button
          >
          <el-button type="warning" icon="el-icon-delete" size="small"
            >删除</el-button
          >
        </el-table-column>
      </el-table>
    </div>
    <!-- page -->
    <div class="box3">
      <el-pagination background layout="prev, pager, next" :total="1000">
      </el-pagination>
    </div>
    <!-- 弹框 -->
    <div class="box1_1">
      <el-dialog
        title="添加新闻"
        :visible.sync="dialogVisible"
        width="35%"
        :before-close="handleClose"
      >
        <div>
          <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="新闻标题">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="新闻作者">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="活动时间">
              <el-col :span="11">
                <el-date-picker
                  type="date"
                  placeholder="选择日期"
                  v-model="form.date1"
                  style="width: 100%"
                ></el-date-picker>
              </el-col>
            </el-form-item>
            <el-form-item label="是否上架">
              <el-switch v-model="form.delivery"></el-switch>
            </el-form-item>
            <el-form-item label="新闻类型">
              <el-checkbox-group v-model="form.type">
                <el-checkbox label="娱乐" name="type"></el-checkbox>
                <el-checkbox label="自媒体" name="type"></el-checkbox>
                <el-checkbox label="疫情" name="type"></el-checkbox>
                <el-checkbox label="国际" name="type"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="新闻内容">
              <el-input type="textarea" v-model="form.desc"></el-input>
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogVisible = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  name: "newsType", //缓存数据
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
      tableData: [
        {
          title: "习近平在海南三亚市考察调研",
          author: "新华社",
          time: "2022-04-11 12:51",
        },
      ],
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      dialogVisible: false,
    };
  },
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
  },
};
</script>

<style lang='scss'>
.newsListWrap {
  padding-top: 10px;
  padding-left: 10px;
  .box3 {
    margin-top: 20px;
    text-align: right;
    margin-right: 20px;
  }
}
</style>